home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #5 & #6 / Amiga Plus CD - 1995 - No. 5 and 6.iso / pd / serien / purity / nr.42 / includes3v1 / includes3v1.lha / Exec / Memory.i < prev    next >
Text File  |  1994-12-04  |  5KB  |  174 lines

  1.  
  2. {
  3.                 exec/memory.i
  4. }
  5.  
  6. {$I "Include:exec/nodes.i" }
  7. {$I "Include:Exec/Interrupts.i"}
  8.  
  9. TYPE
  10.  
  11. { ****** MemChunk **************************************************** }
  12.  
  13.   MemChunk = Record
  14.     mc_Next  : ^MemChunk;       { * pointer to next chunk * }
  15.     mc_Bytes : Integer;         { * chunk byte size     * }
  16.   End;
  17.   MemChunkPtr = ^MemChunk;
  18.  
  19.  
  20. { ****** MemHeader *************************************************** }
  21.  
  22.   MemHeader = Record
  23.     mh_Node       : Node;
  24.     mh_Attributes : Short;       { * characteristics of this region * }
  25.     mh_First      : MemChunkPtr; { * first free region          * }
  26.     mh_Lower,                    { * lower memory bound         * }
  27.     mh_Upper      : Address;     { * upper memory bound+1       * }
  28.     mh_Free       : Integer;     { * total number of free bytes * }
  29.   End;
  30.   MemHeaderPtr = ^MemHeader;
  31.  
  32.  
  33. { ****** MemEntry **************************************************** }
  34.  
  35.   MemUnit = Record
  36.       meu_Reqs  : Integer;      { * the AllocMem requirements * }
  37.       meu_Addr  : Address;      { * the address of this memory region * }
  38.   End;
  39.   MemUnitPtr = ^MemUnit;
  40.  
  41.   MemEntry = Record
  42.     me_Un       : MemUnit;
  43.     me_Length   : Integer;      { * the length of this memory region * }
  44.   End;
  45.   MemEntryPtr = ^MemEntry;
  46.  
  47.  
  48. { ****** MemList ***************************************************** }
  49.  
  50. { * Note: sizeof(struct MemList) includes the size of the first MemEntry! * }
  51.  
  52.   MemList = Record
  53.     ml_Node       : Node;
  54.     ml_NumEntries : Short;      { * number of entries in this struct * }
  55.     ml_ME         : Array [0..0] of MemEntry;    { * the first entry * }
  56.   End;
  57.   MemListPtr = ^MemList;
  58.  
  59. { *----- Memory Requirement Types ---------------------------* }
  60. { *----- See the AllocMem() documentation for details--------* }
  61.  
  62. Const
  63.  
  64.    MEMF_ANY      = %000000000000000000000000;   { * Any type of memory will do * }
  65.    MEMF_PUBLIC   = %000000000000000000000001;
  66.    MEMF_CHIP     = %000000000000000000000010;
  67.    MEMF_FAST     = %000000000000000000000100;
  68.    MEMF_LOCAL    = %000000000000000100000000;
  69.    MEMF_24BITDMA = %000000000000001000000000;   { * DMAable memory within 24 bits of address * }
  70.    MEMF_KICK     = %000000000000010000000000;   { Memory that can be used for KickTags }
  71.  
  72.    MEMF_CLEAR    = %000000010000000000000000;
  73.    MEMF_LARGEST  = %000000100000000000000000;
  74.    MEMF_REVERSE  = %000001000000000000000000;
  75.    MEMF_TOTAL    = %000010000000000000000000;   { * AvailMem: return total size of memory * }
  76.    MEMF_NO_EXPUNGE = $80000000;   {AllocMem: Do not cause expunge on failure }
  77.  
  78.    MEM_BLOCKSIZE = 8;
  79.    MEM_BLOCKMASK = MEM_BLOCKSIZE-1;
  80.  
  81. Type
  82. {***** MemHandlerData *********************************************}
  83. { Note:  This structure is *READ ONLY* and only EXEC can create it!}
  84.  MemHandlerData = Record
  85.         memh_RequestSize,      { Requested allocation size }
  86.         memh_RequestFlags,      { Requested allocation flags }
  87.         memh_Flags  : Integer;             { Flags (see below) }
  88.  end;
  89.  MemHandlerDataPtr = ^MemHandlerData;
  90.  
  91. const
  92.     MEMHF_RECYCLE  = 1; { 0==First time, 1==recycle }
  93.  
  94. {***** Low Memory handler return values **************************}
  95.     MEM_DID_NOTHING = 0;     { Nothing we could do... }
  96.     MEM_ALL_DONE    = -1;    { We did all we could do }
  97.     MEM_TRY_AGAIN   = 1;     { We did some, try the allocation again }
  98.  
  99.  
  100. Procedure AddMemList(size, attr, pri : Integer; base : Address; name : String);
  101.     External;
  102.  
  103. Function AllocAbs(bytesize : Integer; location : Address) : Address;
  104.     External;
  105.  
  106. Function Allocate(mem : MemHeaderPtr; bytesize : Integer) : Address;
  107.     External;
  108.  
  109. Function AllocEntry(mem : MemListPtr) : MemListPtr;
  110.     External;
  111.  
  112. Function AllocMem(bytesize : Integer; reqs : Integer) : Address;
  113.     External;
  114.  
  115. Function AvailMem(attr : Integer) : Integer;
  116.     External;
  117.  
  118. Procedure CopyMem(source, dest : Address; size : Integer);
  119.     External;
  120.  
  121. Procedure CopyMemQuick(source, dest : Address; size : Integer);
  122.     External;
  123.  
  124. Procedure Deallocate(header : MemHeaderPtr; block : Address; size : Integer);
  125.     External;
  126.  
  127. Procedure FreeEntry(memList : MemListPtr);
  128.     External;
  129.  
  130. Procedure FreeMem(memBlock : Address; size : Integer);
  131.     External;
  132.  
  133. Procedure InitStruct(table, memory : Address; size : Integer);
  134.     External;
  135.  
  136. Function TypeOfMem(mem : Address) : Integer;
  137.     External;
  138.  
  139.  
  140. { -- 2.0 functions -- }
  141.  
  142. Function AllocPooled( memsize : Integer; poolheader : Address ): Address;
  143.     External;
  144.  
  145. Function AllocVec( size, reqm : Integer ): Address;
  146.     External;
  147.  
  148. Function CreatePrivatePool( requrements,
  149.                              puddlesize,
  150.                              puddletresh : Integer ): Address;
  151.     External;
  152.  
  153. Procedure DeletePrivatePool( poolheader : Address );
  154.     External;
  155.  
  156. Procedure FreePooled( memory, poolheader : Address );
  157.     External;
  158.  
  159. Procedure FreeVec( memory : Address );
  160.     External;
  161.  
  162.  
  163. {--- functions in V39 or higher (Release 3) ---}
  164. {------ Low memory handler functions }
  165. PROCEDURE AddMemHandler(memhand : InterruptPtr;);
  166.     External;
  167.  
  168. PROCEDURE RemMemHandler(memhand : InterruptPtr);
  169.     External;
  170.  
  171.  
  172.  
  173.  
  174.